package com.example.commons.inspect;

import com.example.commons.exception.BusinessException;
import com.example.commons.math.Decimal;
import org.apache.commons.lang3.StringUtils;

/**
 * 检验是否为空
 */
public class ParamsInspect {

    public static void IsNull(String param, String remark) {
        if (StringUtils.isBlank(param)) {
            throw new BusinessException(remark + "不能为空");
        }
    }

    public static void IsNumber(String number, String remark) {
        try {
            if (-1 == Decimal.bigOrSmall(number, "0")) {
                throw new BusinessException(remark + "有误");
            }
        } catch (NumberFormatException n) {
            throw new BusinessException(remark + "格式有误");
        }
    }
}
